// import React from 'react';
// import { connect } from 'react-redux';
// import PreviewList from '../components/Home/PreviewList';
// import { push } from 'react-router-redux';
// import {bindActionCreators} from 'redux';
// import {actions} from "./HomeRedux";
//
//
// class Home extends React.Component {
//   render() {
//     const { loadArticles, articleList, push } = this.props;
//
//     return (
//       <div>
//         <h1>Home</h1>
//         <PreviewList {...this.props.list} {...this.props.listActions} push={this.props.push} />
//       </div>
//     );
//   }
// }
//
// export default connect(state =>{
//     return {
//         list:state.home.list,
//     };
// },dispatch =>{
//     return {
//         listActions : bindActionCreators(actions,dispatch),
//         push:bindActionCreators(push,dispatch)
//     };
// })(Home);

import React, {Component} from 'react';
import { bindActionCreators } from 'redux';
import {connect} from 'react-redux';
import ArticleTable from "../components/Home/Table";
import ArticleModal from "../components/Home/Modal";
import {tableActions,modalActions} from "./HomeRedux";
import './Home.css';

@connect(state => ({
    table: state.articles.table,
    modal:state.articles.modal
}),dispatch=>({
    tableActions : bindActionCreators(tableActions,dispatch),
    modalActions : bindActionCreators(modalActions,dispatch),
}))
class ArticleCRUD extends Component{
    render(){
        return (
            <div className="page">
                <button onClick={this.props.modalActions.showModal}>新增文章</button>
                <ArticleTable {...this.props.table} {...this.props.tableActions} />
                <ArticleModal {...this.props.modal} {...this.props.modalActions} />
            </div>
        )
    }
}

export default ArticleCRUD;
